package Day2025_02_17;

public class LeetCode1089 {
    public void duplicateZeros(int[] arr) {
        int slow = -1, fast = -1;
        int n = arr.length - 1;
        while (fast < n) {
            if (arr[++slow] == 0) fast++;
            fast++;
        }
        if (fast > n) {
            fast--;
            slow--;
            arr[fast--] = 0;
        }
        while (fast > 0) {
            if (arr[slow] == 0) {
                arr[fast--] = 0;
                arr[fast--] = 0;
                slow--;
            } else arr[fast--] = arr[slow--];
        }
    }

    public static void main(String[] args) {
        int[] arr = {8,4,5,0,0,0,0,7};
//        duplicateZeros(arr);
    }
}
